export default {
    namespaced: true,
    state:()=>( {
        userInfo: {},
        token: ''
    }),
    getters: {
        getUserInfo(state) {
            return state.userInfo;
        },
        getToken(state) {
            return state.token;
        }
    },
    mutations: {
        setToken(state, token) {
            state.token = token;
        },
        setUserInfo(state, userInfo) {
            state.userInfo = userInfo;
        }
    },
    actions: {
        setLoginInfo({ commit }, obj) {
            commit('setToken', obj.token);
            commit('setUserInfo', obj.userInfo);
        },
        clearLoginInfo({ commit }) {
            commit('setToken', "");
            commit('setUserInfo', "");
        },
        exit({ dispatch }) {
            dispatch('clearLoginInfo');
            dispatch('tabs/removeAllPage', {}, {root: true});
        }
    },
}